package LeetCode.day122;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author 16778
 * @date 2025/12/2 8:31
 * @description
 */
public class No3623 {
    public int countTrapezoids(int[][] points) {
        int n = points.length;
        List<Integer> list = new ArrayList<>();
        Arrays.sort(points, (a, b)->a[1]-b[1]);
        int num = 1;
        for (int i = 1; i < n; i++) {
            if(points[i][1]!=points[i-1][1]){
                list.add(num);
                num=1;
            }else{
                num++;
            }
        }
        list.add(num);
        long res = 0;
        long sum = 0;
        for (int i = 0; i < list.size(); i++) {
            long temp = (long)list.get(i)*(list.get(i)-1)/2;
            res = (res+temp*sum)%1000000007;
            sum+=temp;
        }
        return (int)res;
    }
}
